using System.Collections.Generic;

namespace BSDS.Commands.Commands.Creation
{
    public abstract class CommandCreatorBase : ICommandCreator
    {
        protected abstract  bool Supports(Dictionary<string, string> parameters);

        protected abstract ICommand Create(Dictionary<string, string> parameters);

        public bool TryCreate(Dictionary<string, string> parameters, out ICommand command)
        {
            if(Supports(parameters))
            {
                command = Create(parameters);

                return true;
            }

            command = null;
            return false;
        }
    }
}